<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
    <style>
    </style>
</head>
<body>
    <div id="box">
        {{ changeFirstLetterCpt }}      
    </div>
    <script>
        let app = new Vue({
            el: "#box",
            data: {
                letter : "hello world"
            },
            methods: {
                changeFirstLetter(){
                    // 每一次执行都会调用
                }
            },
            computed: {
                changeFirstLetterCpt:{
                    get(){
                        return this.letter[0].toUpperCase() + this.letter.substring(1)
                    },
                    set(val){
                        this.letter = val;
                  }  
                }
                // 只执行一次，记录在缓存中，只有当状态发生改变的时候才会重新进行计算
                
            }
        })
    </script>
</body>
</html>